
const tokens = {
  admin: {
    token: 'admin-token'
  },
  editor: {
    token: 'editor-token'
  }
}

const users = {
  'admin-token': {
    roles: ['admin'],
    introduction: 'I am a super administrator',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Super Admin'
  },
  'editor-token': {
    roles: ['editor'],
    introduction: 'I am an editor',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'Normal Editor'
  }
}

module.exports = [
  // user login
  {
    url: '/login',
    type: 'post',
    response: config => {
      const { username } = config.body
      const token = tokens[username]

      // mock error
      if (!token) {
        return {
          code: 60204,
          message: 'Account and password are incorrect.'
        }
      }

      return {
        code: 200,
        data: token
      }
    }
  },

  // get user info
  {
    url: '/getInfo',
    type: 'get',
    response: config => {
      const { token } = config.query
      const info = users[token]

      // mock error
      if (!info) {
        return {
          code: 50008,
          message: 'Login failed, unable to get user details.'
        }
      }

      return {
        code: 200,
        data: info
      }
    }
  },

  // user logout
  {
    url: '/logout',
    type: 'post',
    response: _ => {
      return {
        code: 200,
        data: 'success'
      }
    }
  },

 // user logout
 {
  url: '/system/user/list',
  type: 'get',
  response: _ => {
    return {
      code: 200,
      data: {
        "total": 2,
        "rows": [
          {
            "createBy": "admin",
            "createTime": "2024-02-16 06:54:48",
            "updateBy": null,
            "updateTime": null,
            "remark": "管理员",
            "userId": 1,
            "deptId": 103,
            "userName": "admin",
            "nickName": "若依",
            "email": "ry@163.com",
            "phonenumber": "15888888888",
            "sex": "1",
            "avatar": "",
            "password": null,
            "status": "0",
            "delFlag": "0",
            "loginIp": "127.0.0.1",
            "loginDate": "2024-02-17T15:04:38.000+08:00",
            "dept": {
              "createBy": null,
              "createTime": null,
              "updateBy": null,
              "updateTime": null,
              "remark": null,
              "deptId": 103,
              "parentId": null,
              "ancestors": null,
              "deptName": "研发部门",
              "orderNum": null,
              "leader": "若依",
              "phone": null,
              "email": null,
              "status": null,
              "delFlag": null,
              "parentName": null,
              "children": []
            },
            "roles": [],
            "roleIds": null,
            "postIds": null,
            "roleId": null,
            "admin": true
          },
          {
            "createBy": "admin",
            "createTime": "2024-02-16 06:54:48",
            "updateBy": null,
            "updateTime": null,
            "remark": "测试员",
            "userId": 2,
            "deptId": 105,
            "userName": "ry",
            "nickName": "若依",
            "email": "ry@qq.com",
            "phonenumber": "15666666666",
            "sex": "1",
            "avatar": "",
            "password": null,
            "status": "0",
            "delFlag": "0",
            "loginIp": "127.0.0.1",
            "loginDate": "2024-02-16T06:54:48.000+08:00",
            "dept": {
              "createBy": null,
              "createTime": null,
              "updateBy": null,
              "updateTime": null,
              "remark": null,
              "deptId": 105,
              "parentId": null,
              "ancestors": null,
              "deptName": "测试部门",
              "orderNum": null,
              "leader": "若依",
              "phone": null,
              "email": null,
              "status": null,
              "delFlag": null,
              "parentName": null,
              "children": []
            },
            "roles": [],
            "roleIds": null,
            "postIds": null,
            "roleId": null,
            "admin": false
          }
        ],
        "code": 200,
        "msg": "查询成功"
      }
    }
  }
},

{
  url: '/system/user/deptTree',
  type: 'get',
  response: _ => {
    return {
      code: 200,
      "data": [
          {
            "id": 100,
            "label": "若依科技",
            "children": [
              {
                "id": 101,
                "label": "深圳总公司",
                "children": [
                  {
                    "id": 103,
                    "label": "研发部门"
                  },
                  {
                    "id": 104,
                    "label": "市场部门"
                  },
                  {
                    "id": 105,
                    "label": "测试部门"
                  },
                  {
                    "id": 106,
                    "label": "财务部门"
                  },
                  {
                    "id": 107,
                    "label": "运维部门"
                  }
                ]
              },
              {
                "id": 102,
                "label": "长沙分公司",
                "children": [
                  {
                    "id": 108,
                    "label": "市场部门"
                  },
                  {
                    "id": 109,
                    "label": "财务部门"
                  }
                ]
              }
            ]
          }
        ]
  }
}
}

]
